<template>
  <div class="edit-popup box-flex">
    <div style="width: 70%">
      <el-card class="!border-none" shadow="never">
        <el-button
          v-perms="['customerlist:add/edit']"
          type="primary"
          v-if="formStatus === FormEnum.ADD"
          @click="addCustomer()"
        >
          <template #icon>
            <icon name="el-icon-Document" />
          </template>
          新增
        </el-button>
        <el-button
          v-perms="['customerlist:add/edit']"
          type="primary"
          v-if="formStatus === FormEnum.EDIT"
          @click="updateCustomer()"
        >
          <template #icon>
            <icon name="el-icon-FolderChecked" />
          </template>
          保存
        </el-button>
      </el-card>
      <el-card class="mt-2 !border-none" shadow="never">
        <el-form
          ref="formRef"
          :model="formData"
          :rules="formRules"
          :inline="true"
          class="formEdit"
          :disabled="disabled"
        >
          <el-collapse v-model="activeNames">
            <el-collapse-item title="基本信息" name="1">
              <el-form-item label="客户编号" prop="customerId" class="w-[45%]" label-width="160px">
                <el-input v-model="formData.id" placeholder="不填写，系统将自动生成" disabled />
              </el-form-item>
              <el-form-item label="客户名称" prop="name" class="w-[45%]" label-width="160px">
                <el-input v-model="formData.name" />
                <!--                                <el-button type="primary"> 查重 </el-button>-->
              </el-form-item>
              <el-form-item label="咨询业务" prop="consultancy" class="w-[45%]" label-width="160px">
                <el-select v-model="formData.detail.consultancy" class="flex-1">
                  <el-option label="服务业" value="服务业" />
                  <el-option label="制造业" value="制造业" />
                </el-select>
              </el-form-item>
              <el-form-item
                label="注册时间"
                prop="registrationDate"
                class="w-[45%]"
                label-width="160px"
              >
                <el-date-picker
                  class="flex-1 !flex"
                  v-model="formData.registrationDate"
                  type="datetime"
                  clearable
                  value-format="YYYY-MM-DD hh:mm:ss"
                />
              </el-form-item>
              <el-form-item
                label="注册资金"
                prop="registeredFund"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.registeredFund" />
              </el-form-item>
              <el-form-item label="企业规模" prop="scale" class="w-[45%]" label-width="160px">
                <el-select class="flex-1" v-model="formData.detail.scale">
                  <el-option label="大型客户" value="大型客户" />
                  <el-option label="中型客户" value="中型客户" />
                  <el-option label="小型客户" value="小型客户" />
                  <el-option label="一级-新" value="一级-新" />
                  <el-option label="一级-老" value="一级-老" />
                  <el-option label="二级-新" value="二级-新" />
                  <el-option label="二级-老" value="二级-老" />
                  <el-option label="三级-新" value="三级-新" />
                </el-select>
              </el-form-item>
              <el-form-item
                label="注册类型"
                prop="registeredType"
                class="w-[45%]"
                label-width="160px"
              >
                <el-select v-model="formData.registeredType" class="flex-1">
                  <el-option label="商标基础" value="商标基础" />
                  <el-option label="商标项目" value="商标项目" />
                </el-select>
              </el-form-item>
              <el-form-item
                label="实缴资本"
                prop="contributedCapital"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.contributedCapital" />
              </el-form-item>
              <el-form-item
                label="员工人数"
                prop="numberOfEmployees"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.numberOfEmployees" />
              </el-form-item>
              <el-form-item label="信用代码" prop="creditCode" class="w-[45%]" label-width="160px">
                <el-input v-model="formData.detail.creditCode" />
              </el-form-item>
              <el-form-item label="企业官网" prop="companyUrl" class="w-[45%]" label-width="160px">
                <el-input v-model="formData.detail.companyUrl" />
              </el-form-item>

              <el-form-item
                label="企业邮箱"
                prop="companyEmail"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.companyEmail" />
              </el-form-item>

              <el-form-item
                label="上游产品"
                prop="upstreamProducts"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.upstreamProducts" />
              </el-form-item>
              <el-form-item
                label="下游产品"
                prop="downstreamProduct"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.downstreamProduct" />
              </el-form-item>
              <el-form-item
                label="技术领域"
                prop="technosphere"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.technosphere" />
              </el-form-item>

              <el-form-item label="省市区" prop="province" class="w-[45%]" label-width="160px">
                <el-cascader
                  v-model="formData.detail.province"
                  :options="cityData"
                  :props="cityProps"
                  @change="handleChange"
                  class="w-[65%]"
                />
              </el-form-item>

              <!-- <el-form-item label="省份" prop="businessAssistant" class="w-[45%]" label-width="160px">
    <el-select v-model="formData.detail.province" class="flex-1">
    </el-select>
</el-form-item>
<el-form-item label="城市" prop="city" class="w-[45%]" label-width="160px">
    <el-select v-model="formData.detail.city" class="flex-1">
    </el-select>
</el-form-item>
<el-form-item label="区县" prop="county" class="w-[45%]" label-width="160px">
    <el-select v-model="formData.detail.county" class="flex-1">
    </el-select>
</el-form-item> -->
              <el-form-item label="详细地址" prop="address" class="w-[45%]" label-width="160px">
                <el-input v-model="formData.detail.address" />
              </el-form-item>
              <el-form-item
                label="违规违法及失信情况"
                prop="breachOfTrust"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.breachOfTrust" />
              </el-form-item>
              <el-form-item
                label="是否园区或基地注册"
                prop="isParkBase"
                class="w-[45%]"
                label-width="300px"
              >
                <el-radio-group v-model="formData.detail.isParkBase">
                  <el-radio label="是" size="large">是</el-radio>
                  <el-radio label="否" size="large">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item
                label="园区或基地名称"
                prop="parkOrBaseName"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.parkOrBaseName" />
              </el-form-item>
              <el-form-item
                label="主导产品是否国内外知名企业直接配套"
                prop="isDirectMatching"
                class="w-[45%]"
                label-width="300px"
              >
                <el-radio-group v-model="formData.detail.isDirectMatching">
                  <el-radio label="是" size="large">是</el-radio>
                  <el-radio label="否" size="large">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="企业名称" prop="companyName" class="w-[45%]" label-width="160px">
                <el-input v-model="formData.companyName" />
              </el-form-item>
              <el-form-item label="客户等级" prop="clientGrade" class="w-[45%]" label-width="160px">
                <el-select class="flex-1" v-model="formData.clientGrade">
                  <el-option label="大型客户" value="大型客户" />
                  <el-option label="中型客户" value="中型客户" />
                  <el-option label="小型客户" value="小型客户" />
                  <el-option label="一级-新" value="一级-新" />
                  <el-option label="一级-老" value="一级-老" />
                  <el-option label="二级-新" value="二级-新" />
                  <el-option label="二级-老" value="二级-老" />
                  <el-option label="三级-新" value="三级-新" />
                </el-select>
              </el-form-item>
              <el-form-item label="抖音/公众号" prop="platform" class="w-[45%]" label-width="160px">
                <el-input v-model="formData.detail.platform" />
              </el-form-item>
              <el-form-item label="主营产品" prop="businessAssistant" label-width="160px">
                <el-table border stripe style="width: 100%">
                  <el-table-column prop="date" label="序号" />
                  <el-table-column prop="name" label="产品名称" width="180" />
                  <el-table-column prop="address" label="营业收入" width="180" />
                </el-table>
              </el-form-item>
              <el-form-item label="" prop="businessAssistant" label-width="160px">
                <el-table border stripe style="width: 100%">
                  <el-table-column prop="date" label="行业领军企业名称" width="180" />
                </el-table>
              </el-form-item>
            </el-collapse-item>
            <el-collapse-item title="联系信息" name="2">
              <el-form-item label="联系人" prop="linkman" class="w-[45%]">
                <el-input v-model="formData.detail.linkman" />
              </el-form-item>
              <el-form-item label="性别" prop="sex" class="w-[45%]">
                <el-select class="flex-1" v-model="formData.detail.sex">
                  <el-option label="男" value="男" />
                  <el-option label="女" value="女" />
                </el-select>
              </el-form-item>
              <el-form-item label="联系电话" prop="phone" class="w-[45%]">
                <el-input v-model="formData.detail.phone" />
              </el-form-item>
              <el-form-item label="联系微信" prop="fax" class="w-[45%]">
                <el-input v-model="formData.detail.wechat" />
              </el-form-item>
              <el-form-item label="联系邮箱" prop="email" class="w-[45%]">
                <el-input v-model="formData.detail.email" />
              </el-form-item>
              <el-form-item label="公司传真" prop="fax" class="w-[45%]">
                <el-input v-model="formData.detail.fax" />
              </el-form-item>
              <el-form-item label="公司座机" prop="specialPlane" class="w-[45%]">
                <el-input v-model="formData.detail.specialPlane" />
              </el-form-item>
            </el-collapse-item>
            <el-collapse-item title="资金财务" name="3">
              <el-form-item
                label="设备固定资金总额"
                prop="managementDeviceMoney"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.managementDeviceMoney" />
              </el-form-item>
              <el-form-item
                label="未来生产设备投资总额"
                prop="managementDeviceInvestMoney"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.managementDeviceInvestMoney" />
              </el-form-item>
              <el-form-item
                label="息化投入情况金额"
                prop="managementPutIntoMoney"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.managementPutIntoMoney" />
              </el-form-item>
              <el-form-item
                label="土地建设"
                prop="managementLandDevelopment"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.managementLandDevelopment" />
              </el-form-item>
              <el-form-item
                label="建设区域"
                prop="managementUseDistrict"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.managementUseDistrict" />
              </el-form-item>
              <el-form-item
                label="计划建设年限"
                prop="managementPlannedConstructionPeriod"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.managementPlannedConstructionPeriod" />
              </el-form-item>
              <el-form-item
                label="上市情况"
                prop="managementListingSituation"
                class="w-[45%]"
                label-width="160px"
              >
                <el-select class="flex-1" v-model="formData.detail.managementListingSituation">
                  <el-option label="1" value="1" />
                  <el-option label="2" value="2" />
                  <el-option label="3" value="3" />
                </el-select>
              </el-form-item>

              <el-form-item
                label="上市计划"
                prop="managementListingPlan"
                class="w-[45%]"
                label-width="160px"
              >
                <el-select class="flex-1" v-model="formData.detail.managementListingPlan">
                  <el-option label="1" value="1" />
                  <el-option label="2" value="2" />
                  <el-option label="3" value="3" />
                </el-select>
              </el-form-item>

              <el-form-item
                label="拟上市地"
                prop="managementIntendedListingPlace"
                class="w-[45%]"
                label-width="160px"
              >
                <el-select class="flex-1" v-model="formData.detail.managementIntendedListingPlace">
                  <el-option label="湖南" value="1" />
                </el-select>
              </el-form-item>
              <el-form-item
                label="融资需求额"
                prop="managementFinancingRequirement"
                class="w-[45%]"
                label-width="160px"
              >
                <el-input v-model="formData.detail.managementFinancingRequirement" />
              </el-form-item>
              <el-form-item
                label="计划融资方式"
                prop="managementPlanFinancingMethod"
                class="w-[45%]"
                label-width="160px"
              >
                <el-select class="flex-1" v-model="formData.detail.managementPlanFinancingMethod">
                  <el-option label="请选择" value="1" />
                </el-select>
              </el-form-item>
              <el-form-item>
                <lastThreeYearsFinancialStatus
                  ref="refFinancial"
                  @updateEvent="updateEvent"
                  :data="managementTableData"
                ></lastThreeYearsFinancialStatus>
              </el-form-item>
            </el-collapse-item>
            <el-collapse-item title="人力资源" name="4">
              <el-form-item label="职工总数" prop="hrWorkCount" class="w-[45%]">
                <el-input v-model="formData.detail.hrWorkCount" />
              </el-form-item>
              <el-form-item label="社保人数" prop="hrSecurityCount" class="w-[45%]">
                <el-input v-model="formData.detail.hrSecurityCount" />
              </el-form-item>
              <el-form-item label="个税人数" prop="hrIndividualCount" class="w-[45%]">
                <el-input v-model="formData.detail.hrIndividualCount" />
              </el-form-item>
              <el-form-item label="研发人数" prop="hrDevelopmentCount" class="w-[45%]">
                <el-input v-model="formData.detail.hrDevelopmentCount" />
              </el-form-item>

              <el-table :data="rlzytableData" style="width: 100%" stripe>
                <el-table-column prop="degree" label="学历"></el-table-column>
                <el-table-column prop="field" label="领域"></el-table-column>
                <el-table-column prop="count" label="职工人数">
                  <template #default="{ row, column }">
                    <el-input v-model="row.count" @input="handleInput(row, column)"></el-input>
                  </template>
                </el-table-column>
              </el-table>
            </el-collapse-item>
            <el-collapse-item title="知识产权" name="5">
              <el-form-item label="专利运营情况">
                <el-checkbox-group v-model="checkList">
                  <el-checkbox label="专利转移转让"> 专利转移转让</el-checkbox>
                  <el-checkbox label="专利质押融资"> 专利质押融资</el-checkbox>
                  <el-checkbox label="专利许可"> 专利许可</el-checkbox>
                  <el-checkbox label="专利无形资产做价入股"> 专利无形资产做价入股 </el-checkbox>
                </el-checkbox-group>
              </el-form-item>
              <el-table
                :data="tableData"
                style="width: 100%"
                border
                class="mt-4"
                size="large"
                stripe
              >
                <el-table-column prop="date" label="年份" min-width="90"></el-table-column>
                <el-table-column prop="" label="专利申请总数" min-width="90">
                  <template #default="scope">
                    <span v-show="!scope.row.editing">{{ scope.row.name }} </span>
                    <el-input v-show="scope.row.editing" v-model="scope.row.name"></el-input>
                  </template>
                </el-table-column>
                <el-table-column prop="" label="专利授权总数">
                  <template #default="scope">
                    <span v-show="!scope.row.editing">{{ scope.row.address }} </span>
                    <el-input v-show="scope.row.editing" v-model="scope.row.address"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="发明申请">
                  <template #default="scope">
                    <span v-show="!scope.row.editing">{{ scope.row.value }} </span>
                    <el-input v-show="scope.row.editing" v-model="scope.row.value"></el-input>
                  </template>
                </el-table-column>
                <el-table-column prop="" label="发明授权">
                  <template #default="scope">
                    <span v-show="!scope.row.editing">{{ scope.row.netProfit }} </span>
                    <el-input v-show="scope.row.editing" v-model="scope.row.netProfit"></el-input>
                  </template>
                </el-table-column>
                <el-table-column prop="" label="实用新型申请" min-width="90">
                  <template #default="scope">
                    <span v-show="!scope.row.editing">{{ scope.row.netProfitRate }} </span>
                    <el-input
                      v-show="scope.row.editing"
                      v-model="scope.row.netProfitRate"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column prop="" label="实用新型授权">
                  <template #default="scope">
                    <span v-show="!scope.row.editing">{{ scope.row.grossLiabilities }} </span>
                    <el-input
                      v-show="scope.row.editing"
                      v-model="scope.row.grossLiabilities"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column prop="" label="PCT专利申请" min-width="90">
                  <template #default="scope">
                    <span v-show="!scope.row.editing">{{ scope.row.researchAndDevelopment }} </span>
                    <el-input
                      v-show="scope.row.editing"
                      v-model="scope.row.researchAndDevelopment"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column prop="" label="PCT专利授权" min-width="120">
                  <template #default="scope">
                    <span v-show="!scope.row.editing">{{ scope.row.proportionOfExpenses }} </span>
                    <el-input
                      v-show="scope.row.editing"
                      v-model="scope.row.proportionOfExpenses"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column prop="" label="软件版权（项）">
                  <template #default="scope">
                    <span v-show="!scope.row.editing">{{ scope.row.ratal }} </span>
                    <el-input v-show="scope.row.editing" v-model="scope.row.ratal"></el-input>
                  </template>
                </el-table-column>
                <el-table-column prop="" label="商标总数" min-width="120">
                  <template #default="scope">
                    <span v-show="!scope.row.editing">{{ scope.row.lev }} </span>
                    <el-input v-show="scope.row.editing" v-model="scope.row.lev"></el-input>
                  </template>
                </el-table-column>
              </el-table>
            </el-collapse-item>
            <el-collapse-item title="标准体系" name="6">
              <div class="font_system">
                公司是否有标准化战略或标准化底层设计?
                <el-radio-group v-model="formData.detail.isStandardizedUnderlyingDesign">
                  <el-radio label="是">是</el-radio>
                  <el-radio label="否">否</el-radio>
                  <el-radio label="考虑">考虑</el-radio>
                </el-radio-group>
              </div>
              <div class="font_system">
                意向产品/服务的标准化主题
                <el-table :data="yxcptableData" stripe border style="width: 100%">
                  <el-table-column prop="category" label="类别" width="180"></el-table-column>
                  <el-table-column label="参标">
                    <template #default="{ row }">
                      <el-input v-model="row.cansu" placeholder="请输入参标"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column label="立项">
                    <template #default="{ row }">
                      <el-input v-model="row.lixiang" placeholder="请输入立项"></el-input>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </el-collapse-item>
            <el-collapse-item title="项目申报" name="7">
              <el-checkbox-group v-model="checkListProject">
                <el-row>
                  <el-col :span="5">
                    <el-checkbox label="高新技术企业认定"> 高新技术企业认定 </el-checkbox>
                  </el-col>
                  <el-col :span="3">
                    <el-checkbox label="双软认定"> 双软认定</el-checkbox>
                  </el-col>
                  <el-col :span="4">
                    <el-checkbox label="专精特新中小企业"> 专精特新中小企业 </el-checkbox>
                  </el-col>
                  <el-col :span="3">
                    <el-checkbox label="科技成果鉴定"> 科技成果鉴定 </el-checkbox>
                  </el-col>
                  <el-col :span="5">
                    <el-checkbox label="工程技术研究中心"> 工程技术研究中心 </el-checkbox>
                  </el-col>
                  <el-col :span="4">
                    <el-checkbox label="科技计划"> 科技计划</el-checkbox>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="5">
                    <el-checkbox label="研发机构建设"> 研发机构建设 </el-checkbox>
                  </el-col>
                  <el-col :span="3">
                    <el-checkbox label="小巨人认定"> 小巨人认定</el-checkbox>
                  </el-col>
                  <el-col :span="4">
                    <el-checkbox label="国家/省科学技术奖"> 国家/省科学技术奖 </el-checkbox>
                  </el-col>
                  <el-col :span="3">
                    <el-checkbox label="单项冠军"> 单项冠军</el-checkbox>
                  </el-col>
                  <el-col :span="5">
                    <el-checkbox label="企业技术中心"> 企业技术中心 </el-checkbox>
                  </el-col>
                  <el-col :span="4">
                    <el-checkbox label="新型研发机构建设"> 新型研发机构建设 </el-checkbox>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="5">
                    <el-checkbox label="国家知识产权优势/示范"> 国家知识产权优势/示范 </el-checkbox>
                  </el-col>
                  <el-col :span="3">
                    <el-checkbox label="绿色工厂"> 绿色工厂</el-checkbox>
                  </el-col>
                  <el-col :span="4">
                    <el-checkbox label="省知识产权示范"> 省知识产权示范 </el-checkbox>
                  </el-col>
                  <el-col :span="3">
                    <el-checkbox label="国家/省专利奖"> 国家/省专利奖 </el-checkbox>
                  </el-col>
                  <el-col :span="5">
                    <el-checkbox label="智能制造试点示范企业"> 智能制造试点示范企业 </el-checkbox>
                  </el-col>
                  <el-col :span="4">
                    <el-checkbox label="质量标杆"> 质量标杆</el-checkbox>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="5">
                    <el-checkbox label="技术创新示范企业"> 技术创新示范企业 </el-checkbox>
                  </el-col>
                  <el-col :span="10">
                    <el-checkbox label="近三年进入创客中国中小企业创新创业大赛全国50强企业组">
                      近三年进入创客中国中小企业创新创业大赛全国50强企业组
                    </el-checkbox>
                  </el-col>
                  <el-col :span="4">
                    <el-checkbox label="《产业基础领域先进技术产品转化应用目录》">
                      《产业基础领域先进技术产品转化应用目录》
                    </el-checkbox>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-checkbox label="是否享受过国家首台（套）重大技术装备保险补偿试点政策">
                      是否享受过国家首台（套）重大技术装备保险补偿试点政策
                    </el-checkbox>
                  </el-col>
                  <el-col :span="4">
                    <el-checkbox label="工业企业知识产权运用试点企业">
                      工业企业知识产权运用试点企业
                    </el-checkbox>
                  </el-col>
                </el-row>
              </el-checkbox-group>
              <el-row>
                <el-col>
                  <el-form-item
                    label="其他"
                    prop="projectApplicationOther"
                    label-width="40px"
                    class="w-[45%]"
                  >
                    <el-input v-model="formData.detail.projectApplicationOther" />
                  </el-form-item>
                </el-col>
              </el-row>
            </el-collapse-item>
            <el-collapse-item title="管理体系认证" name="8">
              <el-checkbox-group v-model="checkListSystem">
                <el-checkbox label="ISO9000质量管理体系认证"> ISO9000质量管理体系认证 </el-checkbox>
                <el-checkbox label="OHSAS18000职业安全健康管理体系认证">
                  OHSAS18000职业安全健康管理体系认证
                </el-checkbox>
                <el-checkbox label="ISO14000环境管理体系认证">
                  ISO14000环境管理体系认证
                </el-checkbox>
                <el-checkbox label="GB/T29490-2023企业知识产权合规管理体系要求认证">
                  GB/T29490-2023企业知识产权合规管理体系要求认证
                </el-checkbox>
              </el-checkbox-group>
              <el-form-item
                label="其他"
                prop="managementSystemCertificationOther"
                label-width="40px"
                class="w-[45%]"
              >
                <el-input v-model="formData.detail.managementSystemCertificationOther" />
              </el-form-item>
            </el-collapse-item>
            <el-collapse-item title="产品获得发达国家或地区权威机构认证情况" name="9">
              <el-checkbox-group v-model="checkListAuthority">
                <el-checkbox label="UL"> UL</el-checkbox>
                <el-checkbox label="CSA"> CSA</el-checkbox>
                <el-checkbox label="ETL"> ETL</el-checkbox>
                <el-checkbox label="GS"> GS</el-checkbox>
              </el-checkbox-group>
              <el-form-item label="其他" prop="customerTownship" label-width="40px" class="w-[45%]">
                <el-input v-model="formData.detail.authorityCertificationOther" />
              </el-form-item>
            </el-collapse-item>
            <el-collapse-item title="产学研及研发机构建设" name="10">
              <el-form-item label="是否有产学研合作" label-width="160px" class="w-[45%]">
                <el-radio-group v-model="formData.detail.institutionsIsCooperation">
                  <el-radio label="是" size="large">是</el-radio>
                  <el-radio label="否" size="large">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="企业是否有技术需求" label-width="160px" class="w-[45%]">
                <el-radio-group v-model="formData.detail.institutionsIsTechnicalDemand">
                  <el-radio label="是" size="large">是</el-radio>
                  <el-radio label="否" size="large">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="是否转让科技成果" label-width="160px" class="w-[45%]">
                <el-radio-group v-model="formData.detail.institutionsIsAchievement">
                  <el-radio label="是" size="large">是</el-radio>
                  <el-radio label="否" size="large">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="是否申请机构" class="w-[45%]" label-width="160px">
                <el-radio-group v-model="formData.detail.institutionsIsOrganization">
                  <el-radio label="是" size="large">是</el-radio>
                  <el-radio label="否" size="large">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="企业是否申报研发项目" label-width="160px" class="w-[45%]">
                <el-radio-group v-model="formData.detail.institutionsIsDeclaration">
                  <el-radio label="是" size="large">是</el-radio>
                  <el-radio label="否" size="large">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="重大研发项目" class="w-[45%]" label-width="160px">
                <el-input v-model="formData.detail.institutionsDevelopmentProject" />
              </el-form-item>
              <el-row class="no-margin">
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>研发机构名称</div>
                </el-col>
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>
                    <el-input v-model="formData.detail.institutionsDevelopmentName" />
                  </div>
                </el-col>
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>认定情况</div>
                </el-col>
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>
                    <el-radio-group v-model="formData.detail.institutionsAscertainmentSituation">
                      <el-radio label="省级" size="large">省级</el-radio>
                      <el-radio label="市级" size="large">市级</el-radio>
                    </el-radio-group>
                  </div>
                </el-col>
              </el-row>
              <el-row class="no-margin">
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>成立时间</div>
                </el-col>
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>
                    <el-input v-model="formData.detail.institutionsFoundingTime" />
                  </div>
                </el-col>
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>研发仪器设备情况（万元）</div>
                </el-col>
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>
                    <el-input v-model="formData.detail.institutionsDeviceMoney" />
                  </div>
                </el-col>
              </el-row>
              <el-row class="no-margin">
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>研发场所面积（平方）</div>
                </el-col>
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>
                    <el-input v-model="formData.detail.institutionsSiteArea" />
                  </div>
                </el-col>
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>研发人员情况（人数）</div>
                </el-col>
                <el-col :span="6" class="col-with-border" style="border: none">
                  <div>
                    <el-input v-model="formData.detail.institutionsDevelopmentCount" />
                  </div>
                </el-col>
              </el-row>
              <el-table
                :data="tableData"
                border
                stripe
                style="width: 100%; margin-top: 20px; margin-bottom: 20px"
              >
                <el-table-column prop="id" label="序号" width="180" />
                <el-table-column prop="name" label="具体院校" />
                <el-table-column prop="amount1" label="年份" />
              </el-table>
              <el-checkbox-group style="margin: 20px 0 0 10px" v-model="checkListResearch">
                <div style="display: flex; border: 1px solid #f2f2f2; padding: 2%">
                  <div class="namebox">
                    <span style="white-space: nowrap">技术研究员</span>
                  </div>
                  <el-form-item style="width: 1230px" label="">
                    <el-checkbox label="国家级1">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0">国家级</span>
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsTechnicalResearcherNational"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>
                    <el-checkbox label="省级1">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0; letter-spacing: 8px"
                          >省级</span
                        >
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsTechnicalResearcherProvincial"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>
                    <el-checkbox label="自建1" style="margin-top: 20px">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0; letter-spacing: 8px"
                          >自建</span
                        >
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsTechnicalResearcherSelfbuild"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>
                  </el-form-item>
                </div>
                <div style="display: flex; border: 1px solid #f2f2f2; padding: 2%">
                  <div class="namebox">
                    <span style="white-space: nowrap">企业技术中心</span>
                  </div>
                  <el-form-item style="width: 1230px" label="">
                    <el-checkbox style="text-align: center" label="国家级2">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0">国家级</span>
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsEnterpriseTechnologyNational"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>

                    <el-checkbox label="省级2">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0; letter-spacing: 8px"
                          >省级</span
                        >
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsEnterpriseTechnologyProvince"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>
                    <el-checkbox label="自建2" style="margin-top: 20px">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0; letter-spacing: 8px"
                          >自建</span
                        >
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsEnterpriseTechnologySelfbuild"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>
                  </el-form-item>
                </div>
                <div style="display: flex; border: 1px solid #f2f2f2; padding: 2%">
                  <div class="namebox">
                    <span style="white-space: nowrap">企业工程中心</span>
                  </div>
                  <el-form-item style="width: 1230px" label="">
                    <el-checkbox style="text-align: center" label="国家级3">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0">国家级</span>
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsEnterpriseCenterNational"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>

                    <el-checkbox label="省级3">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0; letter-spacing: 8px"
                          >省级</span
                        >
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsEnterpriseCenterProvince"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>
                    <el-checkbox label="自建3" style="margin-top: 20px">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0; letter-spacing: 8px"
                          >自建</span
                        >
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsEnterpriseCenterSelfbuild"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>
                  </el-form-item>
                </div>
                <div style="display: flex; border: 1px solid #f2f2f2; padding: 2%">
                  <div class="namebox">
                    <span style="white-space: nowrap">工业设计中心</span>
                  </div>
                  <el-form-item style="width: 1230px" label="">
                    <el-checkbox style="text-align: center" label="国家级4">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0">国家级</span>
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsIndustrialDesignNational"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>

                    <el-checkbox label="省级4">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0; letter-spacing: 8px"
                          >省级</span
                        >
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsIndustrialDesignProvince"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>
                    <el-checkbox label="自建4" style="margin-top: 20px">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0; letter-spacing: 8px"
                          >自建</span
                        >
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsIndustrialDesignSelfbuild"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>
                  </el-form-item>
                </div>
                <div style="display: flex; border: 1px solid #f2f2f2; padding: 2%">
                  <div class="namebox">
                    <span style="white-space: nowrap">重点实验室</span>
                  </div>
                  <el-form-item style="width: 1230px" label="">
                    <el-checkbox style="text-align: center" label="国家级5">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0">国家级</span>
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsKeyLaboratoryNational"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>

                    <el-checkbox label="省级5">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0; letter-spacing: 8px"
                          >省级</span
                        >
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsKeyLaboratoryProvince"
                          placeholder=""
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>
                    <el-checkbox label="自建5" style="margin-top: 20px">
                      <div style="display: flex">
                        <span style="display: block; margin: 8px 4px 0 0; letter-spacing: 8px"
                          >自建</span
                        >
                        <el-input
                          style="display: inline"
                          v-model="formData.detail.institutionsKeyLaboratorySelfbuild"
                        >
                          <template #append>个</template>
                        </el-input>
                      </div>
                    </el-checkbox>
                  </el-form-item>
                </div>
              </el-checkbox-group>

              <div style="display: flex; border: 1px solid #f2f2f2; padding: 2%">
                <div class="namebox">
                  <span style="white-space: nowrap">院士专家工作站</span>
                </div>
                <el-form-item
                  style="width: 1230px"
                  label=""
                  prop="institutionsAcademicianExpertWorkstation"
                >
                  <el-radio-group
                    style="margin: 20px 0 0 10px"
                    v-model="formData.detail.institutionsAcademicianExpertWorkstation"
                  >
                    <el-radio label="有"></el-radio>
                    <el-radio label="无"></el-radio>
                  </el-radio-group>
                </el-form-item>
              </div>
              <div style="display: flex; border: 1px solid #f2f2f2; padding: 2%">
                <div class="namebox">
                  <span style="white-space: nowrap">博士后工作站</span>
                </div>
                <el-form-item style="width: 1230px" label="" prop="institutionsPostdoctoralCentre">
                  <el-radio-group
                    style="margin: 20px 0 0 10px"
                    v-model="formData.detail.institutionsPostdoctoralCentre"
                  >
                    <el-radio label="有"></el-radio>
                    <el-radio label="无"></el-radio>
                  </el-radio-group>
                </el-form-item>
              </div>
            </el-collapse-item>
            <el-collapse-item title="数字化建设" name="11">
              <el-row class="no-margin">
                <el-col
                  :span="7"
                  class="col-with-border col-bg"
                  style="border-bottom: 1px solid rgba(0, 0, 0, 0.1)"
                >
                  <div>
                    <span>企业使用的信息化系统</span>
                  </div>
                </el-col>
                <el-col
                  :span="16"
                  class="col-with-border"
                  style="justify-content: start; padding-left: 40px; padding-top: 20px"
                >
                  <div>
                    <el-form-item>
                      <el-checkbox-group v-model="checkListUseSystem">
                        <el-row>
                          <el-col :span="11">
                            <el-checkbox label="DSS决策支持系统"> DSS决策支持系统 </el-checkbox>
                          </el-col>
                          <el-col :span="9">
                            <el-checkbox label="设计辅助软件"> 设计辅助软件： </el-checkbox>
                          </el-col>
                          <el-col :span="4">
                            <el-checkbox label="PDM产品数据管理系统">
                              PDM产品数据管理系统
                            </el-checkbox>
                          </el-col>
                        </el-row>

                        <el-row>
                          <el-col :span="11">
                            <el-checkbox label="PLM产品生命周期管理系统">
                              PLM产品生命周期管理系统
                            </el-checkbox>
                          </el-col>
                          <el-col :span="9">
                            <el-checkbox label="BPM流程管理系统"> BPM流程管理系统 </el-checkbox>
                          </el-col>
                          <el-col :span="4">
                            <el-checkbox label="MSE制造执行系统"> MSE制造执行系统 </el-checkbox>
                          </el-col>
                        </el-row>
                      </el-checkbox-group>
                    </el-form-item>
                  </div>
                </el-col>
              </el-row>
              <el-row class="no-margin">
                <el-col
                  :span="7"
                  class="col-with-border col-bg"
                  style="border-bottom: 1px solid rgba(0, 0, 0, 0.1)"
                >
                  <div>
                    <span>信息化系统运用情况（需描述）</span>
                  </div>
                </el-col>
                <el-col :span="16">
                  <div style="padding: 2%">
                    <el-row>
                      <el-col>
                        <el-form-item label="系统之间的集成情况" label-width="180px">
                          <el-input
                            type="textarea"
                            style="width: 300px"
                            v-model="formData.detail.systemIntegrated"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col>
                        <el-form-item label="系统与设备之间的集成情况" label-width="180px">
                          <el-input
                            style="width: 300px"
                            type="textarea"
                            v-model="formData.detail.systemDeviceIntegrated"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </div>
                </el-col>
              </el-row>
              <el-row class="no-margin">
                <el-col
                  :span="7"
                  class="col-with-border col-bg"
                  style="border-bottom: 1px solid rgba(0, 0, 0, 0.1)"
                >
                  <div>
                    <span>信息技术类贯标</span>
                  </div>
                </el-col>
                <el-col :span="16" class="col-with-border">
                  <div style="padding: 2%">
                    <el-form-item>
                      <el-checkbox-group v-model="checkListImplementingStandard">
                        <el-checkbox label="DSS"> DSS</el-checkbox>
                        <el-checkbox label="DSMM"> DSMM</el-checkbox>
                      </el-checkbox-group>
                    </el-form-item>
                  </div>
                </el-col>
              </el-row>
              <el-row class="no-margin">
                <el-col
                  :span="7"
                  class="col-with-border col-bg"
                  style="border-bottom: 1px solid rgba(0, 0, 0, 0.1)"
                >
                  <div>
                    <span>企业所获得的信息化荣誉项目</span>
                  </div>
                </el-col>
                <el-col :span="16" class="col-with-border">
                  <div style="padding: 2%">
                    <el-form-item>
                      <el-checkbox-group v-model="checkListHonorsProgram">
                        <el-checkbox label="工业互联网项目"> 工业互联网项目 </el-checkbox>
                        <el-checkbox label="上云上平台标杆项目"> 上云上平台标杆项目 </el-checkbox>
                      </el-checkbox-group>
                    </el-form-item>
                  </div>
                </el-col>
              </el-row>
            </el-collapse-item>
          </el-collapse>
        </el-form>
      </el-card>
    </div>
    <!-- 右侧 -->
    <div style="width: 450px">
      <div>
        <el-button v-perms="['client:clientData:matchItem']" type="primary" v-if="formData.id">
          <router-link
            :to="{
              path: getRoutePath('client:clientData:matchItem'),
              query: {
                id: formData.id
              }
            }"
          >
            匹配项目
          </router-link>
        </el-button>
        <div>
          <el-form
            ref="formRef"
            :model="formData"
            :rules="formRules"
            label-width="70px"
            :disabled="disabled"
            style="padding: 20px; margin-top: 20px; background-color: #f2f2f2"
          >
            <el-form-item label="所属公司" prop="subordinateCompanies">
              <el-input v-model="formData.subordinateCompanies" />
            </el-form-item>
            <el-form-item label="所属部门" prop="department">
              <el-input v-model="formData.department" />
            </el-form-item>
            <el-form-item label="业务人员" prop="servicer">
              <el-input v-model="formData.servicer" />
            </el-form-item>
            <el-form-item label="客服人员" prop="supportStaff">
              <el-input v-model="formData.supportStaff" />
            </el-form-item>
          </el-form>
        </div>
      </div>
      <div style="display: flex; justify-content: space-between; align-items: center">
        <span style="font-weight: bold; color: #89171d; font-size: 18px"> 跟进记录</span>
        <el-button type="primary" style="margin: 10px" :icon="Plus" @click="WriteFollowup = true">
          写跟进
        </el-button>
      </div>
      <el-form
        ref="formRef"
        :model="formData"
        :rules="formRules"
        label-width="70px"
        :disabled="disabled"
        style="padding-right: 10px"
      >
        <el-form-item label="跟进名称" prop="intendedBusiness">
          <el-input v-model="formData.intendedBusiness" placeholder="请输入跟进名称" />
        </el-form-item>
        <el-form-item label="跟进方式" prop="followUpStatus">
          <el-select v-model="formData.followUpStatus" class="flex-1" placeholder="请选择跟进方式">
            <el-option label="电话联系" value="1" />
            <el-option label="微信短信" value="2" />
            <el-option label="电子邮件" value="3" />
          </el-select>
        </el-form-item>
        <el-form-item label="跟进时间" prop="contractState">
          <daterange-picker
            v-model:startTime="formData.contractStartTimeStart"
            v-model:endTime="formData.contractStartTimeEnd"
          />
        </el-form-item>
        <el-form-item label="协助人员" prop="intendedBusiness">
          <el-input v-model="formData.intendedBusiness" />
        </el-form-item>
      </el-form>
      <div>共158条记录</div>
      <div class="flex flex-wrap gap-4" style="margin-top: 20px">
        <el-card v-for="i in 2" :key="i" style="width: 98%">
          <div style="display: flex; align-items: center; padding: 10px 0px">
            <span class="el-avatar el-avatar--circle" style="--el-avatar-size: 34px"
              ><img
                src="http://127.0.0.1:8082/api/static/backend_avatar.png"
                style="object-fit: cover"
            /></span>

            <span style="font-weight: bold; padding: 0px 10px"> 流程01 ▶</span><span>7个月前</span>
          </div>
          <div>从客户公海池抢到</div>
        </el-card>
      </div>
    </div>
    <el-dialog title="添加跟进状态" v-model="WriteFollowup" width="950px">
      <el-form label-width="138px" :inline="true">
        <el-form-item label="客户联系人" prop="customerContact">
          <el-input
            class="w-[285px]"
            v-model="formData.customerContact"
            placeholder="请输入客户联系人"
          />
        </el-form-item>

        <el-form-item label="联系时间" prop="contactTime">
          <el-date-picker
            class="w-[285px] flex-1 !flex"
            v-model="formData.contactTime"
            style="width: 285px"
            type="datetime"
            clearable
            value-format="YYYY-MM-DD hh:mm:ss"
            placeholder="请选择联系时间"
          />
        </el-form-item>
        <el-form-item label="下次跟进时间" prop="followUpTime">
          <el-date-picker
            class="w-[285px] flex-1 !flex"
            v-model="formData.followUpTime"
            style="width: 285px"
            type="datetime"
            clearable
            value-format="YYYY-MM-DD hh:mm:ss"
            placeholder="请选择下次跟进时间"
          />
        </el-form-item>
        <el-form-item label="联系方式" prop="contactWay">
          <el-input class="w-[285px]" v-model="formData.contactWay" placeholder="请输入联系方式" />
        </el-form-item>
        <el-form-item label="联系类型" prop="contactType">
          <el-select
            class="flex-1 w-[285px]"
            v-model="formData.contactType"
            placeholder="请选择联系类型"
          >
            <el-option
              v-for="(item, index) in dictData.test"
              :key="index"
              :label="item.name"
              :value="item.value"
              clearable
              :disabled="!item.status"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="上传附件" prop="fileName">
          <el-input
            class="w-[285px]"
            v-model="formData.fileName"
            placeholder="请输入上传文件名称"
          />
        </el-form-item>
        <el-form-item label="联系内容" prop="contactContent">
          <!-- <editor v-model="formData.contactContent" :height="200" /> -->
          <el-input
            type="textarea"
            class="w-[285px]"
            v-model="formData.contactContent"
            placeholder="请输入备注"
          />
        </el-form-item>
        <el-form-item label="我方联系人" prop="ourContactName">
          <el-input
            class="w-[285px]"
            v-model="formData.ourContactName"
            placeholder="请输入我方联系人"
          />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="WriteFollowup = false">取消</el-button>
          <el-button type="primary" @click="WriteFollowup = false"> 确认</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
<script lang="ts" setup>
import type { FormInstance } from 'element-plus'
import lastThreeYearsFinancialStatus from '@/views/client/clientPortrait/enterpriseBasicInformation/lastThreeYearsFinancialStatus/index.vue'
import { ref, reactive } from 'vue'
import type { PropType } from 'vue'
import feedback from '@/utils/feedback'
import { Plus } from '@element-plus/icons-vue'
import { CUSTOMER_ID } from '@/enums/cacheEnums'
import cache from '@/utils/cache'
import { getRoutePath } from '@/router'
import { customerAdd, customerDetail, customerEdit } from '@/api/customer/customer'

import cityData from '@/assets/city.json'
import { FormEnum } from '@/enums/appEnums'

const addresslist = ref(cityData)
const cityProps = reactive({
  value: 'name', //指定选项的值为addresslist对象的code属性
  label: 'name', //指定选项标签为addresslist对象的name属性
  children: 'children' //指定选项的子选项为addresslist对象的children属性
})
// 表单状态 新增or编辑
const formStatus = computed(() => {
  return route.query.status
})

const handleChange = (value) => {
  console.log(value)
}
const refFinancial = ref()
const test = () => {
  refFinancial.value.updateData()
}

const updateEvent = (x) => {
  const jsonString = JSON.stringify(x)
  formData.detail.managementTableData = jsonString
}

defineProps({
  dictData: {
    type: Object as PropType<Record<string, any[]>>,
    default: () => ({})
  }
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const mode = ref('add')
const popupTitle = computed(() => {
  return mode.value == 'edit' ? '编辑客户列' : '新增客户列'
})
const activeNames = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11']
const activeName = 'clientlist'
const route = useRoute()
const WriteFollowup = ref(false)
const rlzytableData = ref([
  { degree: '博士', field: '理工科', count: '' },
  { degree: '硕士', field: '理工科', count: '' },
  { degree: '本科', field: '理工科', count: '' },
  { degree: '专科', field: '理工科', count: '' },
  { degree: '高中', field: '理工科', count: '' },
  { degree: '中专', field: '理工科', count: '' },
  { degree: '高级职称', field: '理工科', count: '' },
  { degree: '中级职称', field: '理工科', count: '' },
  { degree: '初级职称', field: '理工科', count: '' },
  { degree: '留学归国', field: '', count: '' }
])
const yxcptableData = ref([
  { category: '国际标准', cansu: '', lixiang: '' },
  { category: '国家标准', cansu: '', lixiang: '' },
  { category: '行业标准', cansu: '', lixiang: '' },
  { category: '地方标准', cansu: '', lixiang: '' },
  { category: '团体标准', cansu: '', lixiang: '' },
  { category: '企业标准', cansu: '', lixiang: '' }
])

// 处理输入事件
const handleInput = (row, column) => {
  // 这里可以添加一些逻辑，比如数据验证或者更新其他状态
  console.log(`Updated ${column.property} for ${row.degree}: ${row.count}`)
}
const router = useRouter()
const tableData = ref([
  {
    date: '2021年',
    netProfit: '',
    netProfitRate: '',
    grossLiabilities: '',
    researchAndDevelopment: '',
    proportionOfExpenses: '',
    ratal: '',
    lev: '',
    bankLoan: '',
    exports: '',
    name: '',
    address: '',
    value: '',
    editing: true
  },
  {
    date: '2022年',
    netProfit: '',
    netProfitRate: '',
    grossLiabilities: '',
    researchAndDevelopment: '',
    proportionOfExpenses: '',
    ratal: '',
    lev: '',
    bankLoan: '',
    exports: '',
    name: '',
    address: '',
    value: '',
    editing: true
  },
  {
    date: '2023年',
    netProfit: '',
    netProfitRate: '',
    grossLiabilities: '',
    researchAndDevelopment: '',
    proportionOfExpenses: '',
    ratal: '',
    lev: '',
    bankLoan: '',
    exports: '',
    name: '',
    address: '',
    value: '',
    editing: true
  }
])
const formData = reactive({
  id: '',
  code: '',
  name: '',
  subordinateCompanies: '',
  department: '',
  servicer: '',
  supportStaff: '',
  registrationDate: '',
  registeredFund: '',
  registeredType: '',
  technosphere: '',
  companyName: '',
  clientGrade: '',
  detail: {
    mianId: '',
    consultancy: '',
    scale: '',
    contributedCapital: '',
    numberOfEmployees: '',
    creditCode: '',
    companyUrl: '',
    companyEmail: '',
    upstreamProducts: '',
    downstreamProduct: '',
    province: '',
    city: '',
    county: '',
    address: '',
    breachOfTrust: '',
    isParkBase: '',
    parkOrBaseName: '',
    isDirectMatching: '',
    platform: '',
    mainProductId: '',
    firmName: '',
    projectApplication: [],
    projectApplicationOther: '',
    managementSystemCertification: [],
    managementSystemCertificationOther: '',
    authorityCertification: [],
    authorityCertificationOther: '',
    institutions: '',
    useSystem: [],
    systemIntegrated: '',
    systemDeviceIntegrated: '',
    implementingStandard: [],
    honorsProgram: [],
    linkman: '',
    sex: '',
    phone: '',
    wechat: '',
    email: '',
    fax: '',
    specialPlane: '',
    patentOperation: [],
    intellectualTableData: '',
    isStandardizedUnderlyingDesign: '',
    standardSystemTableData: '',
    hrWorkCount: '',
    hrSecurityCount: '',
    hrIndividualCount: '',
    hrDevelopmentCount: '',
    hrTableData: '',
    institutionsIsCooperation: '',
    institutionsIsTechnicalDemand: '',
    institutionsIsAchievement: '',
    institutionsIsOrganization: '',
    institutionsIsDeclaration: '',
    institutionsDevelopmentProject: '',
    institutionsDevelopmentName: '',
    institutionsAscertainmentSituation: '',
    institutionsFoundingTime: '',
    institutionsDeviceMoney: '',
    institutionsSiteArea: '',
    institutionsDevelopmentCount: '',
    institutionsTableData: '',
    institutionsTechnicalResearcherNational: 0,
    institutionsTechnicalResearcherProvincial: '',
    institutionsTechnicalResearcherSelfbuild: '',
    institutionsEnterpriseTechnologyNational: '',
    institutionsEnterpriseTechnologyProvince: '',
    institutionsEnterpriseTechnologySelfbuild: '',
    institutionsEnterpriseCenterNational: '',
    institutionsEnterpriseCenterProvince: '',
    institutionsEnterpriseCenterSelfbuild: '',
    institutionsIndustrialDesignNational: '',
    institutionsIndustrialDesignProvince: '',
    institutionsIndustrialDesignSelfbuild: '',
    institutionsKeyLaboratoryNational: '',
    institutionsKeyLaboratoryProvince: '',
    institutionsKeyLaboratorySelfbuild: '',
    institutionsAcademicianExpertWorkstation: '',
    institutionsPostdoctoralCentre: '',

    doctorCount: '',
    masterCount: '',
    graduateCount: '',
    juniorCollegeCount: '',
    seniorHighSchoolCount: '',
    technicalSecondaryCount: '',
    titleOfASeniorProfessionalPostCount: '',
    mediumGradeProfessionalTitleCount: '',
    primaryTitleCount: '',
    studyingAbroadCount: '',
    managementDeviceMoney: '',
    managementDeviceInvestMoney: '',
    managementPutIntoMoney: '',
    managementLandDevelopment: '',
    managementUseDistrict: '',
    managementPlannedConstructionPeriod: '',
    managementListingSituation: '',
    managementListingPlan: '',
    managementIntendedListingPlace: '',
    managementFinancingRequirement: '',
    managementPlanFinancingMethod: '',
    managementTableData: ''
  }
})

const formRules = {
  caseType: [
    {
      required: true,
      message: '请选择案件类型',
      trigger: ['blur']
    }
  ],
  customerNameChinese: [
    {
      required: true,
      message: '请输入客户名称(中)',
      trigger: ['blur']
    }
  ],
  businessPersonnel: [
    {
      required: true,
      message: '请输入业务人员',
      trigger: ['blur']
    }
  ]
}
const caseType = ref<string[]>([])
const options = [
  {
    value: '0',
    label: '专利'
  },
  {
    value: '2',
    label: '商标'
  },
  {
    value: '3',
    label: '版权'
  },
  {
    value: '4',
    label: '科技服务'
  },
  {
    value: '5',
    label: '法律案件'
  },
  {
    value: '6',
    label: '调查案'
  }
]

const handleSubmit = async () => {
  await formRef.value?.validate()
  const data: any = { ...formData }
  //   mode.value == "edit"
  //     ? await customerlistEdit(data)
  //     : await customerlistAdd(data);
  //  popupRef.value?.close();
  if (route.query.id) {
    await customerlistEdit(data)
  } else {
    await customerlistAdd(data)
  }
  router.back()
  feedback.msgSuccess('操作成功')
  emit('success')
}

//知识产权
const checkList = ref<string[]>([])
//项目申报
const checkListProject = ref<string[]>([])
//管理体系认证
const checkListSystem = ref([])
//产品获得发达国家或地区权威机构认证情况
const checkListAuthority = ref([])
//企业使用的信息化系统
const checkListUseSystem = ref([])
//信息技术类贯标
const checkListImplementingStandard = ref([])
//企业所获得的信息化荣誉项目
const checkListHonorsProgram = ref([])

//产学研机构建设
const checkListResearch = ref([])

const open = (type = 'add') => {
  mode.value = type
  popupRef.value?.open()
}

const setFormData = async (data: Record<string, any>) => {
  for (const key in formData) {
    if (data[key] != null && data[key] != undefined) {
      //@ts-ignore
      formData[key] = data[key]
    }
  }
}

const managementTableData = ref({})
const getDetail = async () => {
  const data = await customerDetail({
    id: route.query.id
  })

  data.detail.province = [data.detail.province, data.detail.city, data.detail.county]

  setFormData(data)

  //财务数据表
  managementTableData.value = data.detail.managementTableData
  //人力资源表
  let b = data.detail.hrTableData.replace(/\\(.)/g, '$1')
  b = b.slice(1, -1)
  const a = JSON.parse(b)
  rlzytableData.value = a
  //专利操作表
  const c = JSON.parse(data.detail.patentOperation)
  checkList.value = c

  let d = data.detail.intellectualTableData.replace(/\\(.)/g, '$1')
  d = d.slice(1, -1)
  tableData.value = JSON.parse(d)

  //标准体系
  let e = data.detail.standardSystemTableData.replace(/\\(.)/g, '$1')
  e = e.slice(1, -1)
  yxcptableData.value = JSON.parse(e)

  //项目申报
  let f = data.detail.projectApplication.replace(/\\(.)/g, '$1')
  f = JSON.parse(f)
  if (f != null) checkListProject.value = f

  //管理体系认证
  f = data.detail.managementSystemCertification.replace(/\\(.)/g, '$1')
  f = JSON.parse(f)
  if (f != null) checkListSystem.value = f

  //产品获得发达国家或地区权威机构认证情况
  f = data.detail.authorityCertification.replace(/\\(.)/g, '$1')
  f = JSON.parse(f)
  if (f != null) checkListAuthority.value = f

  //产学研数据表
  console.log(data.detail.institutionsTableData)
  f = data.detail.institutionsTableData.replace(/\\(.)/g, '$1')
  f = f.slice(1, -1)
  f = JSON.parse(f)
  if (f != null) checkListResearch.value = f

  //企业使用的信息化系统
  console.log(data.detail.useSystem)
  f = data.detail.useSystem.replace(/\\(.)/g, '$1')
  f = JSON.parse(f)
  if (f != null) checkListUseSystem.value = f

  //信息技术类贯标
  console.log(data.detail.implementingStandard)
  f = data.detail.implementingStandard.replace(/\\(.)/g, '$1')
  f = JSON.parse(f)
  if (f != null) checkListImplementingStandard.value = f

  //企业所获得的信息化荣誉项目
  console.log(data.detail.honorsProgram)
  f = data.detail.honorsProgram.replace(/\\(.)/g, '$1')
  f = JSON.parse(f)
  if (f != null) checkListHonorsProgram.value = f
}

const addCustomer = async () => {
  cache.remove(CUSTOMER_ID)
  formData.detail.patentOperation = checkList.value
  formData.detail.projectApplication = checkListProject.value
  formData.detail.managementSystemCertification = checkListSystem.value
  formData.detail.implementingStandard = checkListImplementingStandard.value
  formData.detail.useSystem = checkListUseSystem.value
  formData.detail.authorityCertification = checkListAuthority.value
  formData.detail.honorsProgram = checkListHonorsProgram.value
  formData.detail.projectApplication = formData.detail.projectApplication.toString()
  formData.detail.managementSystemCertification =
    formData.detail.managementSystemCertification.toString()
  formData.detail.authorityCertification = formData.detail.authorityCertification.toString()
  formData.detail.useSystem = formData.detail.useSystem.toString()
  formData.detail.implementingStandard = formData.detail.implementingStandard.toString()
  formData.detail.honorsProgram = formData.detail.honorsProgram.toString()
  formData.detail.patentOperation = formData.detail.patentOperation.toString()
  formData.detail.doctorCount = rlzytableData.value[0].count
  formData.detail.masterCount = rlzytableData.value[1].count
  formData.detail.graduateCount = rlzytableData.value[2].count
  formData.detail.juniorCollegeCount = rlzytableData.value[3].count
  formData.detail.seniorHighSchoolCount = rlzytableData.value[4].count
  formData.detail.technicalSecondaryCount = rlzytableData.value[5].count
  formData.detail.titleOfASeniorProfessionalPostCount = rlzytableData.value[6].count
  formData.detail.mediumGradeProfessionalTitleCount = rlzytableData.value[7].count
  formData.detail.primaryTitleCount = rlzytableData.value[8].count
  formData.detail.studyingAbroadCount = rlzytableData.value[9].count

  const data: any = { ...formData }
  const customer = await customerAdd(data)
  cache.set(CUSTOMER_ID, customer.id)
  getCustomerDetail()
  feedback.msgSuccess('新增成功')
  emit('success')
}

const updateCustomer = async () => {
  refFinancial.value.updateData()

  formData.detail.county = formData.detail.province[2]
  formData.detail.city = formData.detail.province[1]
  formData.detail.province = formData.detail.province[0]
  formData.detail.hrTableData = JSON.stringify(rlzytableData.value)
  formData.detail.patentOperation = JSON.stringify(checkList.value)
  formData.detail.intellectualTableData = JSON.stringify(tableData.value)

  formData.detail.standardSystemTableData = JSON.stringify(yxcptableData.value)
  formData.detail.projectApplication = JSON.stringify(checkListProject.value)
  formData.detail.managementSystemCertification = JSON.stringify(checkListSystem.value)
  formData.detail.authorityCertification = JSON.stringify(checkListAuthority.value)
  formData.detail.institutionsTableData = JSON.stringify(checkListResearch.value)
  formData.detail.useSystem = JSON.stringify(checkListUseSystem.value)
  formData.detail.implementingStandard = JSON.stringify(checkListImplementingStandard.value)
  formData.detail.honorsProgram = JSON.stringify(checkListHonorsProgram.value)

  const data: any = { ...formData }

  await customerEdit(data)
  getDetail()
  feedback.msgSuccess('保存成功')
  emit('success')
}

const getCustomerDetail = async () => {
  feedback.msgSuccess('取数据')

  if (cache.get(CUSTOMER_ID) != null && cache.get(CUSTOMER_ID) != '') {
    const data = await customerDetail({
      id: cache.get(CUSTOMER_ID)
    })
    setFormData(data)
    console.log(formData.detail.province)
  }
}

// getCustomerDetail()

route.query.id && getDetail()

const disabled = ref(false)

const disabledAll = async () => {
  disabled.value = true
  getDetail()
}

const handleClose = () => {
  emit('close')
}

defineExpose({
  open,
  setFormData,
  getDetail
})
</script>
<style scoped>
.formEdit .el-form-item {
  /* width: 590px; */
}

::v-deep .el-collapse-item__header {
  padding-left: 54px;
  background-color: var(--el-bg-color-collapse);
  font-size: 16px;
  font-weight: 600;
  color: var(--el-text-color-collapse);
}

.namebox {
  /* padding: 0px 50px; */
  min-width: 175px;
  background-color: var(--el-bg-color-collapse);
  display: flex;
  justify-content: center;
  align-items: center;
}

.col-with-border {
  border: 1px solid var(--el-bg-color-collapse);

  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 0px;
}

.col-bg {
  background-color: var(--el-bg-color-collapse);
}

.no-margin {
  margin: 10px 0 0 0;
  /* 去除el-row的外边距 */
}

::v-deep .el-collapse-item__wrap {
  padding-top: 20px;
}

.box-flex {
  display: flex;
}

.no-border .el-input__inner {
  border: none;
  /* 去除边框 */
  box-shadow: none;
  /* 去除焦点时的阴影 */
  width: 100%;
}

.font_system {
  font-size: 18px;
}

.el-row {
  margin-bottom: 0;
}
</style>
